package com.example.tianyidemo.controller;

import com.example.tianyidemo.pojo.DeleteRequest;
import com.example.tianyidemo.pojo.Result;
import com.example.tianyidemo.service.DelcricleService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@CrossOrigin//准许跨域请求
@RestController//包含@Controller（三层架构声明控制器）和@ResponseBody（转化json格式）
    public class DelcricleController {

    @Autowired
    private DelcricleService delcricleService;
        @DeleteMapping("/deletecricle")
    public Result deleteCricle(@RequestBody DeleteRequest request) {
        String uniqueStr = request.getUniqueStr();
        System.out.println(uniqueStr);
        boolean isSuccess =delcricleService.deletecricle(uniqueStr);
        if (isSuccess) {
            return Result.success("房源删除成功");
        } else {
            return Result.error("房源删除失败");
        }
    }
}

